import asyncio
from aiogram import Bot, Dispatcher
from handlers import router
import psycopg2


dbname = "dbname"
user = "user"
password = "password"
host = "host"
port = "port"

async def if_con():
    conn = psycopg2.connect(dbname=dbname, user=user, password=password, host=host, port=port)
    if conn:
        print("соединение установлено")
    else:
        print("что-то с базой")


async def main():
    await if_con()
    bot = Bot(token ="TOKEN")
    dp = Dispatcher()
    dp.include_router(router)
    await dp.start_polling(bot)

if __name__ == '__main__':
    try:
        print('bot start')
        asyncio.run(main())
    except KeyboardInterrupt:
        print('выключен')